package com.entrogy.controller;

import com.alibaba.excel.EasyExcel;
import com.entrogy.bean.*;
import com.entrogy.service.*;
import com.entrogy.utils.constants.ErrorEnum;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.*;

/**
 * @ClassName FinalNoticeController
 * @Description
 * @Author luoxingjiang
 * @Date 2019-12-11 上午 11:15
 * @Version 1.0
 **/
@RestController
@RequestMapping("/final-notice")
@Api(description = "期末通知书控制层")
public class FinalNoticeController {

    private static final Logger logger = LoggerFactory.getLogger(FinalNoticeController.class);

    @Autowired
    private FinalNoticeService finalNoticeService;

    @Autowired
    private UserService userService;

    @Autowired
    private PositionService positionService;

    @Value("${show.image.url}")
    private String showImage;

    @Autowired
    private ClassService classService;

    @Autowired
    private ExamService examService;

    @Autowired
    private StudentScoreService studentScoreService;

    @Autowired
    private ParentService parentService;


    @GetMapping(value = "/list-comment")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
    })
    @ApiOperation(value = "查询评语列表")
    public Msg listComment(String uid) {
        Integer schoolCode;
        if (StringUtils.isNoneBlank(uid)){
            schoolCode = userService.getSchoolCodeByUserId(uid);
        }else {
            schoolCode = (Integer) SecurityUtils.getSubject().getSession().getAttribute("schoolCode");
        }
        if (schoolCode == null){
            return Msg.fail(ErrorEnum.E_90003, ErrorEnum.E_90003.getErrorMsg());
        }
        List<FinalNoticeCommentTemplateEntity> commentList = finalNoticeService.listComment(schoolCode, null, uid);
        return Msg.success().add("commentList", commentList);
    }

    @PostMapping(value = "/insert-comment")
    @ApiOperation(value = "新增评语模板")
    public Msg insertComment(@RequestBody FinalNoticeCommentTemplateEntity finalNoticeCommentTemplate) {
        Integer schoolCode;
        if (StringUtils.isNoneBlank(finalNoticeCommentTemplate.getCreateUserId())){
            schoolCode = userService.getSchoolCodeByUserId(finalNoticeCommentTemplate.getCreateUserId());
        }else {
            schoolCode = (Integer) SecurityUtils.getSubject().getSession().getAttribute("schoolCode");
        }
        if (schoolCode == null){
            return Msg.fail(ErrorEnum.E_90003, ErrorEnum.E_90003.getErrorMsg());
        }
        finalNoticeCommentTemplate.setSchoolCode(schoolCode);
        Integer finalNoticeCommentTemplateId = finalNoticeService.insertComment(finalNoticeCommentTemplate);
        return Msg.success().add("finalNoticeCommentTemplateId", finalNoticeCommentTemplateId);
    }

    @PostMapping(value = "/student-evaluate")
    @ApiOperation(value = "教师给学生写评语")
    public Msg studentEvaluate(@RequestBody List<FinalNoticeTeacherCommentEntity> teacherCommentList) {
        if (teacherCommentList.size() > 0){
            Integer schoolCode = userService.getSchoolCodeByUserId(teacherCommentList.get(0).getCreateUserId());
            boolean insertResult = finalNoticeService.insertStudentEvaluate(teacherCommentList, schoolCode);
            return Msg.success();
        }else {
            return Msg.fail(ErrorEnum.E_90003, ErrorEnum.E_90003.getErrorMsg());
        }
    }

    @PutMapping(value = "/update-parent-evaluate")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "finalNoticeId", value = "通知书id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "parentEvaluate", value = "家长评价", dataType = "String", paramType = "query"),
    })
    @ApiOperation(value = "家长添加评论与建议")
    public Msg updateStudentEvaluate(Integer finalNoticeId, String parentEvaluate, String uid) {
        FinalNoticeEntity finalNotice = new FinalNoticeEntity();
        finalNotice.setId(finalNoticeId).setParentEvaluate(parentEvaluate);
        boolean insertResult = finalNoticeService.updateStudentFinalNotice(finalNotice);
        return Msg.success();
    }

    @GetMapping(value = "/list-student-forEvaluate")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "term", value = "学期", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "termOfYear", value = "学年", dataType = "String", paramType = "query"),
    })
    @ApiOperation(value = "获取学生列表（用于教师写评语，0未评1已评）")
    public Msg listStudentForEvaluate(String uid, String term, String termOfYear) {
        if (!StringUtils.isNoneBlank(uid)){
            uid = (String) SecurityUtils.getSubject().getSession().getAttribute("userId");
        }
        boolean isClassLeader = positionService.checkPosition(uid, 16);
        if (isClassLeader){
            List<StudentBasicInfoEntity> studentList = finalNoticeService.listStudentForEvaluate(uid, term, termOfYear);
            return Msg.success().add("studentList", studentList).add("showImage", showImage);
        }else {
            return Msg.fail(ErrorEnum.E_101, "对不起，您没有权限！");
        }
    }

    @GetMapping(value = "/list-student-forFinalNotice")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "term", value = "学期", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "termOfYear", value = "学年", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "gradeId", value = "年级", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "studentId", value = "学生id", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "studentName", value = "学生姓名", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "currentPage", value = "当前页", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query"),
    })
    @ApiOperation(value = "获取学生列表（用于通知书查看）")
    public Msg listStudentForFinalNotice(String uid, String term, String termOfYear, Integer gradeId, String studentName, Integer currentPage, Integer pageSize, Integer studentId) {
        Integer schoolCode;
        if (currentPage == null || pageSize == null){
            currentPage = 0;
            pageSize = 0;
        }
        if (uid.startsWith("1")){
            schoolCode = userService.getSchoolCodeByUserId(uid);
            PageHelper.startPage(currentPage, pageSize);
            List<StudentBasicInfoEntity> studentList = finalNoticeService.listStudentForFinalNotice(schoolCode, gradeId, term, termOfYear, studentName, null);
            PageInfo<StudentBasicInfoEntity> pageInfo = new PageInfo<>(studentList);
            return Msg.success().add("studentList", studentList).add("totalCount", pageInfo.getTotal());
        }else if (uid.startsWith("3")){
            schoolCode = parentService.getSchoolCodeByParentId(uid);
            // 如果家长没传studentId的话，那么就是查询他的所有孩子
            List<Integer> studentIdList = new ArrayList<>();
            if (studentId == null){
                List<StudentBasicInfoEntity> studentList = parentService.listStudentByParentId(uid);
                studentList.forEach(student -> {
                    studentIdList.add(student.getId());
                });
            }else {
                studentIdList.add(studentId);
            }
            PageHelper.startPage(currentPage, pageSize);
            List<StudentBasicInfoEntity> studentList = finalNoticeService.listStudentForFinalNotice(schoolCode, gradeId, term, termOfYear, studentName, studentIdList);
            PageInfo<StudentBasicInfoEntity> pageInfo = new PageInfo<>(studentList);
            return Msg.success().add("studentList", studentList).add("totalCount", pageInfo.getTotal());
        }
        return Msg.fail(ErrorEnum.E_102, ErrorEnum.E_102.getErrorMsg());
    }

    @GetMapping(value = "/list-finalNoticeContent")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "term", value = "学期", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "termOfYear", value = "学年", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "gradeId", value = "年级", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "currentPage", value = "当前页", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query"),
    })
    @ApiOperation(value = "获取通知书内容模板")
    public Msg listFinalNoticeContent(String uid, String term, String termOfYear, Integer gradeId, Integer currentPage, Integer pageSize) {
        Integer schoolCode;
        if (StringUtils.isNoneBlank(uid)){
            schoolCode = userService.getSchoolCodeByUserId(uid);
        }else {
            schoolCode = (Integer) SecurityUtils.getSubject().getSession().getAttribute("schoolCode");
        }
        if (schoolCode == null){
            return Msg.fail(ErrorEnum.E_90003, ErrorEnum.E_90003.getErrorMsg());
        }
        // 是否查询全部，0表示只查询未删除的，1表示查询全部
        Integer deleteStatus = 0;
        if (currentPage == null || pageSize == null){
            currentPage = 0;
            pageSize = 0;
        }
        PageHelper.startPage(currentPage, pageSize);
        List<FinalNoticeContentEntity> contentTemplateList = finalNoticeService.listFinalNoticeContent(schoolCode, term, termOfYear, gradeId, deleteStatus);
        PageInfo<FinalNoticeContentEntity> pageInfo = new PageInfo<>(contentTemplateList);
        return Msg.success().add("contentTemplateList", contentTemplateList).add("totalCount", pageInfo.getTotal());
    }

    @DeleteMapping(value = "/delete-finalNoticeContent")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "finalNoticeContentId", value = "内容id", dataType = "Integer", paramType = "query"),
    })
    @ApiOperation(value = "删除通知书内容模板")
    public Msg deleteFinalNoticeContent(String uid, Integer finalNoticeContentId) {
        if (uid == null){
            uid = (String) SecurityUtils.getSubject().getSession().getAttribute("userId");
        }
        logger.info("用户：{}正在删除通知书模板！", uid);
        boolean deleteFinalNoticeContentResult = finalNoticeService.deleteFinalNoticeContent(finalNoticeContentId);
        return Msg.success();
    }

    @PutMapping(value = "/update-finalNoticeContent")
    @ApiOperation(value = "更新通知书内容模板")
    public Msg updateFinalNoticeContent(@RequestBody FinalNoticeContentEntity finalNoticeContent) {
        String uid = (String) SecurityUtils.getSubject().getSession().getAttribute("userId");
        logger.info("用户：{}正在更新通知书模板！", uid);
        boolean updateFinalNoticeContentResult = finalNoticeService.updateFinalNoticeContent(finalNoticeContent);
        return Msg.success();
    }

    @PutMapping(value = "/insert-finalNoticeContent")
    @ApiOperation(value = "新增通知书内容模板")
    public Msg insertFinalNoticeContent(@RequestBody FinalNoticeContentEntity finalNoticeContent) {
        // 校验该年级该学年该学期是否已经有模板了
        if (!StringUtils.isNoneBlank(finalNoticeContent.getCreateUserId())){
            String userId = (String) SecurityUtils.getSubject().getSession().getAttribute("userId");
            finalNoticeContent.setCreateUserId(userId);
        }
        Integer schoolCode = userService.getSchoolCodeByUserId(finalNoticeContent.getCreateUserId());
        List<FinalNoticeContentEntity> contentList = finalNoticeService.listFinalNoticeContent(schoolCode, finalNoticeContent.getTerm(), finalNoticeContent.getTermOfYear(), finalNoticeContent.getGradeId(), 0);
        if (contentList.size() > 0){
            return Msg.fail(ErrorEnum.E_101, "对不起，新增失败，该年级在该学年的该学期已经配置了通知书内容模板，不能重复新增！");
        }
        boolean insertFinalNoticeContentResult = finalNoticeService.insertFinalNoticeContent(finalNoticeContent);
        return Msg.success();
    }

    @PostMapping(value = "/generate-finalNotice")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "term", value = "学期", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "termOfYear", value = "学年", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "gradeId", value = "年级", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "examId", value = "考试id", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "finalNoticeContentId", value = "通知书内容id", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "override", value = "是否覆盖，0否1是", dataType = "Integer", paramType = "query", required = true),
    })
    @ApiOperation(value = "生成通知书")
    public Msg generateFinalNotice(String uid, String term, String termOfYear, Integer gradeId, Integer examId, Integer finalNoticeContentId, Integer override) {
        Integer schoolCode = userService.getSchoolCodeByUserId(uid);
        // 前端暂时不传通知书模板id，通过去查询该年级该学年该学期的通知书内容模板id
        if (finalNoticeContentId == null){
            List<FinalNoticeContentEntity> contentList = finalNoticeService.listFinalNoticeContent(schoolCode, term, termOfYear, gradeId, 0);
            if (contentList.size() > 0){
                finalNoticeContentId = contentList.get(0).getId();
            }else {
                return Msg.fail(ErrorEnum.E_101, "对不起，生成通知书失败，该年级还未配置通知书内容模板，请移步PC端配置后再进行生成！");
            }
        }
        boolean generateResult = finalNoticeService.generateFinalNotice(uid, term, termOfYear, gradeId, examId, finalNoticeContentId, override);
        return Msg.success();
    }

    @GetMapping(value = "/get-generateStatus")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "term", value = "学期", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "termOfYear", value = "学年", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "gradeId", value = "年级", dataType = "Integer", paramType = "query", required = true),
    })
    @ApiOperation(value = "获取该学年该学期该年级是否已经生成过通知书")
    public Msg getGenerateStatus(String uid, String term, String termOfYear, Integer gradeId) {
        Integer schoolCode = userService.getSchoolCodeByUserId(uid);
        Integer totalCount = finalNoticeService.countFinalNotice(term, termOfYear, gradeId, schoolCode);
        return Msg.success().add("isGenerate", totalCount > 0 ? 1 : 0);
    }

    @GetMapping(value = "/get-student-finalNotice")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "finalNoticeId", value = "通知书id", dataType = "Integer", paramType = "query"),
    })
    @ApiOperation(value = "获取学生通知书详情")
    public Msg getStudentFinalNotice(String uid, Integer finalNoticeId) {
        Integer schoolCode = null;
        if (uid.startsWith("1")){
            schoolCode = userService.getSchoolCodeByUserId(uid);
        }else if (uid.startsWith("3")){
            schoolCode = parentService.getSchoolCodeByParentId(uid);
        }
        if (schoolCode == null){
            return Msg.fail(ErrorEnum.E_90003, ErrorEnum.E_90003.getErrorMsg());
        }
        FinalNoticeEntity finalNotice = finalNoticeService.getFinalNotice(finalNoticeId, schoolCode);
        return Msg.success().add("finalNotice", finalNotice);
    }

    @GetMapping("/exportFinalScore")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "selectSchoolCode", value = "学校id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "term", value = "学期", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "termOfYear", value = "学年", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "gradeId", value = "年级", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "isExportScore", value = "是否按分数导出，1表示按分数导出，0表示按等级导出", dataType = "Integer", paramType = "query", required = true),
    })
    @ApiOperation(value = "导出期末成绩与评语")
    public Msg exportFinalScore(String uid, String term, String termOfYear, Integer gradeId, Integer isExportScore, Integer selectSchoolCode, HttpServletResponse response) {
        ServletOutputStream out;
        Integer schoolCode;
        if (StringUtils.isNoneBlank(uid)){
            schoolCode = userService.getSchoolCodeByUserId(uid);
        }else {
            schoolCode = selectSchoolCode;
        }
        if (schoolCode == null){
            return Msg.fail(ErrorEnum.E_90003, ErrorEnum.E_90003.getErrorMsg());
        }
        List<StudentBasicInfoEntity> studentList = finalNoticeService.listStudentForFinalNotice(schoolCode, gradeId, term, termOfYear, null, null);
        if (studentList.size() == 0){
            return Msg.fail(ErrorEnum.E_101, "对不起，导出失败，该学年该学期该年级的通知书还未生成，不能进行导出操作！");
        }
        Integer examId = studentList.get(0).getExamId();
        String gradeName = classService.getClassById(gradeId, schoolCode).getClassName();
        String scoreTableName = examService.findScoreTableNameByExamId(examId);
        // 查询出所有班级此次考试的成绩用于excel的导出
        List<StudentScoreEntity> scoreList = finalNoticeService.listStudentFinalExamScore(examId, gradeId, scoreTableName);
        List<StaticCourseEntity> staticCourses = studentScoreService.findExamStaticCourse(examId);
        try{
            out = response.getOutputStream();
            response.setContentType("multipart/form-data");
            response.setCharacterEncoding("utf-8");
            String fileName = URLEncoder.encode("《" + termOfYear + "学年" + term + "学期" + gradeName + "》" + "期末成绩&评语表","utf-8");
            response.setHeader("Content-disposition", "attachment;filename="+fileName+".xlsx");
            // 写sheet1，表头数据动态传入
            // 查询该场考试考了哪些科目以及科目的分数，用于设置动态表头并实现分数的填充
            List<List<String>> head = new ArrayList<>();
            List<String> headColumn1 = new ArrayList<>();
            headColumn1.add("班级");
            head.add(headColumn1);
            List<String> headColumn2 = new ArrayList<>();
            headColumn2.add("姓名");
            head.add(headColumn2);
            for (int i = 0; i < staticCourses.size(); i++) {
                // 科目表头
                List<String> headColumn3 = new ArrayList<>();
                String courseName = staticCourses.get(i).getCourseName();
                headColumn3.add(courseName);
                head.add(headColumn3);
                if (isExportScore == 1){
                    // 科目班级排名表头
                    List<String> headColumn4 = new ArrayList<>();
                    headColumn4.add(courseName + "班级排名");
                    head.add(headColumn4);
                    // 科目年级排名表头
                    List<String> headColumn5 = new ArrayList<>();
                    headColumn5.add(courseName + "年级排名");
                    head.add(headColumn5);
                }
            }
            // 只有按分数导出才导出分数列
            if (isExportScore == 1){
                List<String> headColumn6 = new ArrayList<>();
                headColumn6.add("总分");
                head.add(headColumn6);
                List<String> headColumn7 = new ArrayList<>();
                headColumn7.add("总分班级排名");
                head.add(headColumn7);
                List<String> headColumn8 = new ArrayList<>();
                headColumn8.add("总分年级排名");
                head.add(headColumn8);
                List<String> headColumn9 = new ArrayList<>();
                headColumn9.add("理综/文综");
                head.add(headColumn9);
                List<String> headColumn10 = new ArrayList<>();
                headColumn10.add("理综/文综班级排名");
                head.add(headColumn10);
                List<String> headColumn11 = new ArrayList<>();
                headColumn11.add("理综/文综年级排名");
                head.add(headColumn11);
            }
            List<String> headColumn12 = new ArrayList<>();
            headColumn12.add("教师评语");
            head.add(headColumn12);
            // 动态添加表头，适用一些表头动态变化的场景
            EasyExcel.write(out)
                    // 这里放入动态头
                    .head(head).sheet("sheet1")
                    // 当然这里数据也可以用 List<List<String>> 去传入
                    .doWrite(createDynamicModelList(scoreList, staticCourses, isExportScore));
            // 关闭流
            out.close();
        }catch (Exception e) {
            e.printStackTrace();
            return Msg.fail(ErrorEnum.E_101, "对不起，处理失败，请联系管理员！");
        }
        return Msg.success().add("scoreList", scoreList);
    }

    // 根据动态列生成动态的数据
    private List<List<Object>> createDynamicModelList(List<StudentScoreEntity> scoreList, List<StaticCourseEntity> staticCourses, Integer isExportScore){
        List<List<Object>> rows = new ArrayList<>();
        for (int i = 0; i < scoreList.size(); i++) {
            StudentScoreEntity temp = scoreList.get(i);
            List<ScoreDetailEntity> tempScoreDetailEntity = temp.getScoreDetailEntities();
            List<Object> row = new ArrayList<>();
            row.add(temp.getClassName());
            row.add(temp.getStudentName());
            for (int k = 0; k < staticCourses.size(); k++) {
                StaticCourseEntity staticCourseEntity = staticCourses.get(k);
                for (int j = 0; j < tempScoreDetailEntity.size(); j++) {
                    ScoreDetailEntity scoreDetailEntity = tempScoreDetailEntity.get(j);
                    // 写每一行成绩数据时，需要比较静态课程id是否对应，否则成绩可能会错位
                    if (staticCourseEntity.getId() == scoreDetailEntity.getStaticCourseId().intValue()){
                        if (isExportScore == 1){
                            row.add(scoreDetailEntity.getScore());
                            row.add(scoreDetailEntity.getCourseClassRank());
                            row.add(scoreDetailEntity.getCourseGradeRank());
                        }else {
                            // 不按分数导出时，就是按等级导出，分数和等级的转换关系如下
                            // 优秀 得分率80%及以上
                            // 良好 得分率70%-79%
                            // 合格 得分率60%-得分率69%
                            // 待合格 得分率60%以下
                            Double score = scoreDetailEntity.getScore();
                            Double courseTotalScore = scoreDetailEntity.getCourseTotalScore();
                            if (courseTotalScore == null){
                                // 没有设置科目分数的话，总分默认为100
                                courseTotalScore = 100d;
                            }
                            // 计算得分率
                            Double scoringAverage = score / courseTotalScore;
                            if (scoringAverage >= 0.8){
                                row.add("A");
                            }else if (scoringAverage >=0.7){
                                row.add("B");
                            }else if (scoringAverage >= 0.6){
                                row.add("C");
                            }else {
                                row.add("D");
                            }
                        }
                    }
                }
            }
            if (isExportScore == 1){
                row.add(temp.getStudentTotalScore());
                row.add(temp.getClassRank());
                row.add(temp.getGradeRank());
                row.add(temp.getScienceOrArtsTotal());
                row.add(temp.getScienceOrArtsClassRank());
                row.add(temp.getScienceOrArtsGradeRank());
            }
            row.add(temp.getTeacherComment());
            rows.add(row);
        }
        return rows;
    }

}
